﻿using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Text;
using OrderApi.Models;

namespace order_client
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            string baseUrl = "https://localhost:7053/api/order";
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            HttpContent content = new StringContent(JsonConvert.SerializeObject(todo), Encoding.UTF8, "application/json");
            var task = client.PostAsync(baseUrl, content);
            task.Wait();

            var task2 = client.GetStringAsync(baseUrl);
            List<Order> orders = JsonConvert.DeserializeObject<List<Orders>>(task2.Result);
            orders.ForEach(t => Console.WriteLine(t.toString()));
        }
    }
}